
jQuery.md=function(opt){
	 var modalObj=opt.modal;
	 var timeout=opt.time;
	 var url=opt.url;
	 var zIndex=99;
	 var thW,thH;

	 bheight = function(){
	  if ($.browser.msie && $.browser.version < 7) {
	    var scrollHeight = Math.max(
		  document.documentElement.scrollHeight,
		  document.body.scrollHeight
	    );
	    var offsetHeight = Math.max(
		  document.documentElement.offsetHeight,
		  document.body.offsetHeight
	    );

	    if (scrollHeight < offsetHeight) {
		  return $(window).height();
	    } else {
		  return scrollHeight;
	    }
	  } else {
	    return $(document).height();
	  }
	}
	 bwidth = function() {
	   if ($.browser.msie && $.browser.version < 7) {
	     var scrollWidth = Math.max(
		 document.documentElement.scrollWidth,
		 document.body.scrollWidth
	   );
	   var offsetWidth = Math.max(
		 document.documentElement.offsetWidth,
		 document.body.offsetWidth
	   );

	   if (scrollWidth < offsetWidth) {
		 return $(window).width();
	   } else {
		return scrollWidth;
	   }
	  } else {
	    return $(document).width();
	  }
	}
	 $(modalObj).css({display:"block","z-index":zIndex + 1});
	 
	 $("<div id='grey_div'></div>").appendTo("body").css({height: bheight ,width: bwidth,"z-index":zIndex }).bgIframe();
	
	  if(url==undefined){
		thW=$(modalObj).width();
		thH=$(modalObj).height();
		g();
	 }
	 function g(){	
	    $(modalObj).css({top : w()[0] , left : w()[1] });
		$(".grey_close").live("click",closeGrey);
		$(window).resize(bg); 
		$(window).scroll(bg);
		if(timeout!=undefined) hideGrey();
	 }
	 
	 function w(){
		var st=document.documentElement.scrollTop;//滚动条距顶部的距离
		var sl=document.documentElement.scrollLeft;//滚动条距左边的距离
		var ch=document.documentElement.clientHeight;//屏幕的高度
		var cw=document.documentElement.clientWidth;//屏幕的宽度
		var objT=Number(st)+(Number(ch)-Number(thH))/2;
		var objL=Number(sl)+(Number(cw)-Number(thW))/2;
		return [objT,objL];
	 }
	 function bg(){
		 $("#grey_div").css({height: bheight ,width: bwidth });
		 $(modalObj).css({top : w()[0] , left : w()[1] });
	 }
	 function closeGrey(){
		$(modalObj).css("display", "none");
		$("#grey_div").remove();
	 }
	 function hideGrey(){
		$(modalObj).fadeOut(timeout,function(){
		  $("#grey_div").remove();
		});
	 }
	};

	(function($) {

		$.fn.bgIframe = $.fn.bgiframe = function(s) {
			if ($.browser.msie && /6.0/.test(navigator.userAgent)) {
				s = $.extend( {
					top : 'auto',
					left : 'auto',
					width : 'auto',
					height : 'auto',
					opacity : true,
					src : 'javascript:false;'
				}, s || {});
				var prop = function(n) {
					return n && n.constructor == Number ? n + 'px' : n;
				}, html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'
						+ s.src
						+ '"'
						+ 'style="display:block;position:absolute;z-index:-1;'
						+ (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');'
								: '')
						+ 'top:'
						+ (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')'
								: prop(s.top))
						+ ';'
						+ 'left:'
						+ (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')'
								: prop(s.left))
						+ ';'
						+ 'width:'
						+ (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')'
								: prop(s.width))
						+ ';'
						+ 'height:'
						+ (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')'
								: prop(s.height)) + ';' + '"/>';
				return this.each(function() {
					if ($('> iframe.bgiframe', this).length == 0)
						this.insertBefore(document.createElement(html),
								this.firstChild);
				});
			}
			return this;
		};
	})(jQuery);